package m.fun.model;

import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.store.model.GoodsStockRecord;
import m.store.model.StoreGoods;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "tf_count_detail", description = "盘点明细")
public class CountDetail extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("count.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="count_oid",table= CountInfo.class,description="所属盘点")
    private CountInfo count;
    @LinkTableMeta(name="record_oid",table= GoodsStockRecord.class,description="库存记录")
    private GoodsStockRecord record;
    @LinkTableMeta(name="goods_oid",table= StoreGoods.class,description="商品")
    private StoreGoods goods;
    @FieldMeta(name="oper_date",type= FieldType.DATE,description="操作时间")
    private Date operDate;
    @FieldMeta(name="num",type= FieldType.INT,description="数量")
    private Integer num;
    @FieldMeta(name="price",type= FieldType.DOUBLE,description="单价")
    private Double price;
    @FieldMeta(name="preferential",type= FieldType.DOUBLE,description="总优惠")
    private Double preferential;
    @FieldMeta(name="amount",type= FieldType.DOUBLE,description="金额")
    private Double amount;
    @FieldMeta(name="preferential_price",type= FieldType.DOUBLE,description="优惠后单价")
    private Double preferentialPrice;
    @FieldMeta(name = "remark",type = FieldType.STRING,length = 500,description = "备注")
    private String remark;

    public CountInfo getCount() {
        return count;
    }

    public void setCount(CountInfo count) {
        this.count = count;
    }

    public GoodsStockRecord getRecord() {
        return record;
    }

    public void setRecord(GoodsStockRecord record) {
        this.record = record;
    }

    public StoreGoods getGoods() {
        return goods;
    }

    public void setGoods(StoreGoods goods) {
        this.goods = goods;
    }

    public Date getOperDate() {
        return operDate;
    }

    public void setOperDate(Date operDate) {
        this.operDate = operDate;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getPreferential() {
        return preferential;
    }

    public void setPreferential(Double preferential) {
        this.preferential = preferential;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Double getPreferentialPrice() {
        return preferentialPrice;
    }

    public void setPreferentialPrice(Double preferentialPrice) {
        this.preferentialPrice = preferentialPrice;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
